# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaSearchRequestFacetSpecFacetKey do
  @moduledoc """
  Specifies how a facet is computed.

  ## Attributes

  *   `caseInsensitive` (*type:* `boolean()`, *default:* `nil`) - True to make facet keys case insensitive when getting faceting values with prefixes or contains; false otherwise.
  *   `contains` (*type:* `list(String.t)`, *default:* `nil`) - Only get facet values that contain the given strings. For example, suppose "category" has three values "Action > 2022", "Action > 2021" and "Sci-Fi > 2022". If set "contains" to "2022", the "category" facet only contains "Action > 2022" and "Sci-Fi > 2022". Only supported on textual fields. Maximum is 10.
  *   `intervals` (*type:* `list(GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaInterval.t)`, *default:* `nil`) - Set only if values should be bucketed into intervals. Must be set for facets with numerical values. Must not be set for facet with text values. Maximum number of intervals is 30.
  *   `key` (*type:* `String.t`, *default:* `nil`) - Required. Supported textual and numerical facet keys in Document object, over which the facet values are computed. Facet key is case-sensitive.
  *   `orderBy` (*type:* `String.t`, *default:* `nil`) - The order in which documents are returned. Allowed values are: * "count desc", which means order by SearchResponse.Facet.values.count descending. * "value desc", which means order by SearchResponse.Facet.values.value descending. Only applies to textual facets. If not set, textual values are sorted in [natural order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical intervals are sorted in the order given by FacetSpec.FacetKey.intervals.
  *   `prefixes` (*type:* `list(String.t)`, *default:* `nil`) - Only get facet values that start with the given string prefix. For example, suppose "category" has three values "Action > 2022", "Action > 2021" and "Sci-Fi > 2022". If set "prefixes" to "Action", the "category" facet only contains "Action > 2022" and "Action > 2021". Only supported on textual fields. Maximum is 10.
  *   `restrictedValues` (*type:* `list(String.t)`, *default:* `nil`) - Only get facet for the given restricted values. Only supported on textual fields. For example, suppose "category" has three values "Action > 2022", "Action > 2021" and "Sci-Fi > 2022". If set "restricted_values" to "Action > 2022", the "category" facet only contains "Action > 2022". Only supported on textual fields. Maximum is 10.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :caseInsensitive => boolean() | nil,
          :contains => list(String.t()) | nil,
          :intervals =>
            list(
              GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaInterval.t()
            )
            | nil,
          :key => String.t() | nil,
          :orderBy => String.t() | nil,
          :prefixes => list(String.t()) | nil,
          :restrictedValues => list(String.t()) | nil
        }

  field(:caseInsensitive)
  field(:contains, type: :list)

  field(:intervals,
    as: GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaInterval,
    type: :list
  )

  field(:key)
  field(:orderBy)
  field(:prefixes, type: :list)
  field(:restrictedValues, type: :list)
end

defimpl Poison.Decoder,
  for:
    GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaSearchRequestFacetSpecFacetKey do
  def decode(value, options) do
    GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaSearchRequestFacetSpecFacetKey.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for:
    GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaSearchRequestFacetSpecFacetKey do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
